<%--
 管理员对用户的删除操作
  User: gyy
  Date: 2021-04-08
  Time: 11:34
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<html lang="en">

<head>
    <c:import url="commons.jsp"></c:import>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>SB Admin</title>
    <!-- Bootstrap core CSS-->
    <link href="${pd}/statics/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <!-- Custom fonts for this template-->
    <link href="${pd}/statics/vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <!-- Page level plugin CSS-->
    <link href="${pd}/statics/vendor/datatables/dataTables.bootstrap4.css" rel="stylesheet">
    <!-- Custom styles for this template-->
    <link href="${pd}/statics/css/sb-admin.css" rel="stylesheet">
    <script src="${pd}/statics/js/jquery.js"></script>
    <script>

    </script>

    <script>
        function deleteAlert(id){
            var htm="";
            var tbody=$("#tbody");
            $.ajax({
                url:"deleteUser.action",
                data:{
                    "id":id
                },
                success:function (data){
                    for (var i = 0; i < data.length; i++) {
                        htm+="<tr>"
                            +"<td><input name='ids' type='checkbox' value='"+data[i].lId+"'/></td>"
                            +"<td>"+data[i].id+"</td>"
                            +"<td>"+data[i].userName+"</td>"
                            +"<td>"+data[i].sex+"</td>"
                            +"<td>"+data[i].birthday+"</td>"
                            +"<td>"+data[i].like+"</td>"
                            +"<td>"+data[i].lId+"</td>"
                            +"<td>"+data[i].address+"</td>"
                            +"<td>"+data[i].tel+"</td>"
                            +"<td>"+data[i].number+"</td>"
                            +"<td><input class='btn btn-yellow btn-w-md' onclick='deleteAlert("+data[i].lId+")' value='删除' type='button'></td>"

                            +"</tr>"


                    }
                    tbody.html(htm);
                }
            })
        }
    </script>
    <script>
        //全选
        function selectUserAll(obj) {
            console.log(obj);
            if (obj.checked == true) {
                //打开全选，下面的所有选择框都祖选择
                $("[name='ids']").prop("checked",true);
            } else {
                //关闭全选
                $("[name='ids']").prop("checked",false);
            }
        }
    </script>

</head>

<body class="fixed-nav sticky-footer bg-dark" id="page-top">

<c:import url="adminNav.jsp"></c:import>
<div class="content-wrapper">
    <div class="container-fluid">
        <!-- 用户信息-->
        <div class="card mb-3">
            <div class="card-header">
                <i class="fa fa-table"></i> 用户信息</div>

            <div class="card-body">
                <div class="table-responsive">
                    <form action="adminDelect.action" method="post" >
                        <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
                            <thead>
                            <tr>
                                <th> <input type="checkbox" onclick="selectUserAll(this)"></th>
                                <th>编号</th>
                                <th>姓名</th>
                                <th>性别</th>
                                <th>生日</th>
                                <th>爱好</th>
                                <th>所属俱乐部</th>
                                <th>地址</th>
                                <th>电话</th>
                                <th>锻炼次数</th>
                            </tr>
                            </thead>

                            <tbody id="tbody">
                            <c:forEach var="user" items="${userList}">
                                <tr>
                                    <td><input name="ids" type="checkbox" value="${user.lId}" /></td>
                                    <td>${user.id}</td>
                                    <td>${user.userName}</td>
                                    <td>${user.sex}</td>
                                    <td>${user.birthday}</td>
                                    <td>${user.like}</td>
                                    <td>${user.lId}</td>
                                    <td>${user.address}</td>
                                    <td>${user.tel}</td>
                                    <td>${user.number}</td>
                                    <td> <input class="btn btn-yellow btn-w-md" onclick="deleteAlert(${user.id})"
                                                value="删除" type="button" /></td>
                                </tr>
                            </c:forEach>
                            </tbody>

                        </table>

                        <div style="text-align: center">
                            <input class="btn btn-yellow btn-w-md" value="删除" type="submit" onclick="deleteAlert()"   id="btn"/>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>


<!-- Bootstrap core JavaScript-->
<%--    <script src="statics/vendor/jquery/jquery.min.js"></script>--%>
<script src="${pd}/statics/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- Core plugin JavaScript-->
<script src="${pd}/statics/vendor/jquery-easing/jquery.easing.min.js"></script>
<!-- Page level plugin JavaScript-->
<%--    <script src="statics/vendor/datatables/jquery.dataTables.js"></script>--%>
<script src="${pd}/statics/vendor/datatables/dataTables.bootstrap4.js"></script>
<!-- Custom scripts for all pages-->
<script src="${pd}/statics/js/sb-admin.min.js"></script>
<!-- Custom scripts for this page-->
<script src="${pd}/statics/js/sb-admin-datatables.min.js"></script>
</div>
</body>

</html>
